import { createParamDecorator, ExecutionContext } from '@nestjs/common';
import { UsersService } from '../users/users.service';
import { User } from '../entity/user.entity';
import { Repository, Like } from 'typeorm';

export const CurrentUser = createParamDecorator(
  async (data: unknown, ctx: ExecutionContext) => {
    const request = ctx.switchToHttp().getRequest();
    let user = {
        id:null,
      }
    if (user) {
      user.id= request.user.sub
      request.user = user;
    }


    return request.user;
  },
);
